# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=docbook5-xml
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
_vers_50x=(5.0 5.0.1)
_vers_51x=(5.1)
_vers_5x=$_vers_50x
_vers_5x+=$_vers_51x
pkgver=${_vers_51x[-1]}
pkgrel=1
pkgdesc="a complete rewrite of the well-known DocBook 4 XML schema (DTD, Relax NG, W3C schema) for Docbook 5.X (mingw-w64)"
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=('unzip')
optdepends=('perl: for docbook v4 upgrade tools')
url="https://docbook.org/schemas/5x"
license=('MIT')
for _ver in ${_vers_50x[@]}; do
  source+=("https://docbook.org/xml/$_ver/docbook-$_ver.zip")
  noextract+=("docbook-$_ver.zip")
done
for _ver in ${_vers_51x[@]}; do
  source+=("https://docbook.org/xml/5.1/docbook-v${_ver}-os.zip")
  noextract+=("docbook-v${_ver}-os.zip")
done
sha512sums=('a245796881762cf001f0d32b7c87315cba0454750d6b4178e4546357e320e2ab602d84c08a7e44329f406a8d32340605671c351e87c0b9097582ebf6d10fede4'
            'df85ab724d3205086dfbab40419e268d5bf183b028ed8c58d30068bdc82c1e10fc05bf167d5efcdbeb6b6c9c8dbf96ca4f979fcc6da2e2fea99cbf1bd8aaad30'
            'b55f8eda4dcff9d4ebd31876bc33c244ef3884afc167da1425531266963ba64000fbe619ec7c049ae65c0aab864a5a7228caef08b53f546e2686296d97190873')
install=docbook5-xml-${CARCH}.install

build() {

  # docbook-5.0x
  for ver in ${_vers_50x[@]}; do
    mkdir -p docbook-xml-${ver}
    bsdtar -C docbook-xml-${ver} -xf docbook-${ver}.zip
  done

  for ver in ${_vers_51x[@]}; do
    mkdir -p docbook-xml-${ver}
    bsdtar -C docbook-xml-${ver} -xf docbook-v${ver}-os.zip
  done
}

package() {
  local ver xml
  local _cat

  local _docbook5dir="${pkgdir}${MINGW_PREFIX}/share/xml/docbook-xml"

  mkdir -p "${pkgdir}${MINGW_PREFIX}/etc/xml"

  for ver in ${_vers_50x[@]}; do
    pushd docbook-xml-${ver}
      _cat=docbook-${ver}.xml
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --create "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      mkdir -p ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/dtd/ \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/rng/ \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/sch/ \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/xsd/ \
               ${pkgdir}${MINGW_PREFIX}/share/doc/docbook5-schemas \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/stylesheet/docbook-${ver}/ \
               ${pkgdir}${MINGW_PREFIX}/bin

      cp -r docbook-${ver}/docs/* ${pkgdir}${MINGW_PREFIX}/share/doc/docbook5-schemas
      cp docbook-${ver}/catalog.xml ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/catalog-docbook-${ver}.xml
      cp -r docbook-${ver}/dtd/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/dtd/
      cp -r docbook-${ver}/rng/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/rng/
      cp -r docbook-${ver}/sch/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/sch/
      cp -r docbook-${ver}/xsd/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/xsd/
      cp -r docbook-${ver}/tools/db4-upgrade.xsl ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/stylesheet/docbook-${ver}/
      cp -r docbook-${ver}/tools/db4-entities.pl ${pkgdir}${MINGW_PREFIX}/bin
      cp -r docbook-${ver}/docbook.nvdl ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/docbook.nvdl

      ${MINGW_PREFIX}/bin/xmlcatalog  --create --noout "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "public" \
          "-//OASIS//DTD DocBook XML V${ver}//EN" \
          "http://www.oasis-open.org/docbook/xml/${ver}/docbookx.dtd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ## dtd dir
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/dtd/docbook.dtd" \
          "../../share/xml/docbook/schema/${ver}/dtd/docbook.dtd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/dtd/docbook.dtd" \
          "../../share/xml/docbook/schema/${ver}/dtd/docbook.dtd" \
          "$pkgdir${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/dtd/docbook.dtd" \
          "../../share/xml/docbook/schema/${ver}/dtd/docbook.dtd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/dtd/docbook.dtd" \
          "../../share/xml/docbook/schema/${ver}/dtd/docbook.dtd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      #rng dir
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/rng/docbook.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/rng/docbook.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/rng/docbookxi.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/rng/docbookxi.rng" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rng" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/rng/docbook.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/rng/docbook.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/rng/docbookxi.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/rng/docbookxi.rnc" \
          "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      # xsd dir
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/docbook.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbook.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/docbook.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbook.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/xsd/docbook.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbook.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/xsd/docbook.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbook.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/docbookxi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbookxi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/docbookxi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbookxi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/xsd/docbookxi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbookxi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/xsd/docbookxi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/docbookxi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/xsd/xi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/xsd/xi.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xi.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xlink.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xlink.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xlink.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xlink.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/xsd/xlink.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xlink.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/xsd/xlink.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xlink.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xml.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xml.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/xsd/xml.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xml.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/xsd/xml.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xml.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/xsd/xml.xsd" \
          "../../share/xml/docbook/schema/${ver}/xsd/xml.xsd" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ##sch dir
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/sch/docbook.sch" \
          "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/sch/${ver}/docbook.sch" \
          "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/sch/docbook.sch" \
          "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/sch/docbook.sch" \
          "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      # 5.0 dir
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://www.oasis-open.org/docbook/xml/${ver}/docbook.nvdl" \
          "../../share/xml/docbook/schema/${ver}/docbook.nvdl" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://www.oasis-open.org/docbook/xml/${ver}/docbook.nvdl" \
          "../../share/xml/docbook/schema/${ver}/docbook.nvdl" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteSystem" \
          "http://docbook.org/xml/${ver}/docbook.nvdl" \
          "../../share/xml/docbook/schema/${ver}/docbook.nvdl" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "rewriteURI" \
          "http://docbook.org/xml/${ver}/docbook.nvdl" \
          "../../share/xml/docbook/schema/${ver}/docbook.nvdl" \
          "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

   popd

  done

  #//DOCBOOK 5.1
  mkdir -p "${pkgdir}${MINGW_PREFIX}/etc/xml"

  for ver in ${_vers_51x[@]}; do
    pushd docbook-xml-${ver}
      _cat=docbook-${ver}.xml
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --create "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      mkdir -p ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/rng/ \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/sch/ \
               ${pkgdir}${MINGW_PREFIX}/share/doc/docbook5.1-schemas \
               ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/stylesheet/docbook-${ver}/ \
               ${pkgdir}${MINGW_PREFIX}/bin

      cp -r docbook-v5.1-os.* ${pkgdir}${MINGW_PREFIX}/share/doc/docbook5.1-schemas
      cp  schemas/catalog.xml ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/catalog-docbook-${ver}.xml
      cp -r schemas/rng/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/rng/
      cp -r schemas/sch/* ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/sch/
      cp -r tools/db4-upgrade.xsl ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/stylesheet/docbook-${ver}/
      cp -r tools/db4-entities.pl ${pkgdir}${MINGW_PREFIX}/bin
      cp -r schemas/docbook.nvdl ${pkgdir}${MINGW_PREFIX}/share/xml/docbook/schema/${ver}/docbook.nvdl

      ${MINGW_PREFIX}/bin/xmlcatalog  --create --noout "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      
      msg2 "Assembly ${ver}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/assembly.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/assembly.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/assembly.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/assembly.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
     
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/assembly.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/assembly.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/assembly.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/assembly.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      msg2 "dbits ${ver}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/dbits.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/dbits.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/dbits.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/dbits.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
     
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/dbits.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/dbits.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/dbits.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/dbits.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      msg2 "docbook ${ver}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/docbook.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/docbook.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbook.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/docbook.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/docbook.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      msg2 "docbookxi ${ver}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/rngdocbookxi.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/docbookxi.rng" \
        "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rng" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/rng/docbookxi.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://docbook.org/xml/${ver}/rng/docbookxi.rnc" \
        "../../share/xml/docbook/schema/${ver}/rng/docbookxi.rnc" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"

      # Schematron
      ${MINGW_PREFIX}/bin/xmlcatalog --noout --add "uri" \
        "http://www.oasis-open.org/docbook/xml/${ver}/sch/docbook.sch" \
        "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
      ${MINGW_PREFIX}/bin/xmlcatalog  --noout --add "uri" \
        "http://docbook.org/xml/${ver}/sch/docbook.sch" \
        "../../share/xml/docbook/schema/${ver}/sch/docbook.sch" \
        "${pkgdir}${MINGW_PREFIX}/etc/xml/${_cat}"
    popd

  done
}
